#include "gpio.h"
#include "gpio_m01.h"
#include "igslib_iutil.h"
#include "gpio_dragonball.h"
#include "m01_testpattern.h"


namespace igslib
{
	IGPIOManager* CGPIOManager::instance = 0;
	IGPIOManager* CGPIOManager::GetInstance() 
	{
		if ( instance == 0 )
		{
			instance = new CGPIOManager();
		}
		return instance ;
	}
    IGPIO* CGPIOManager::NewM01GPIO(const int& num)
    {
        IGPIO* rtn = nullptr;
        rtn = new gpio_m01(num);
        cpns.insert(rtn);
        return rtn;
    }
	IGPIO* CGPIOManager::New_ProjMCU(const std::string& name)
	{
		IGPIO* rtn = nullptr;
		if(name == "DragonBallRace")
		{	
			count++;
			rtn = new gpio_Grgn(count); 
			cpns.insert(rtn);
		}
		else if (name == "M01_TestPattern")
		{
			count++;
			rtn = new M01_gpio(count); 
			cpns.insert(rtn);
		}else if(name == "DragonWarrior")
		{	
			count++;
			rtn = new gpio_Grgn(count); 
			cpns.insert(rtn);
		}
		
        return rtn;
	}
}

extern "C"
{
	igslib::IGPIOManager* GetGPIOManagerInstance()
	{
		return igslib::CGPIOManager::GetInstance();
	}
}
